#include "Material.h"

#include "Shader.h"
#include "Texture.h"
#include "ShaderUniform.h"

std::map<int, std::string> Material::materialsNames;
std::map<std::string, std::shared_ptr<Material>> Material::materials;
 
Material::Material(std::string name, std::shared_ptr<Shader> shader)
{
	this->name = name;
	this->shader = shader;
	
	useShadowMap = false;
	castShadow = false;
}

 
Material::Material(std::string name, bool useShadowMap, bool castShadow, std::shared_ptr<Shader> shader)
{
	this->name = name;
	this->shader = shader;
	
	this->castShadow = castShadow;
	this->useShadowMap = useShadowMap;

	if(useShadowMap)
	{
		std::shared_ptr<Texture> texObject = Texture::textureMap.at("ShadowMap");
		shader->AddParameter(Shader::Shadow, texObject);
	}
}

Material::~Material()
{

}

void Material::Bind()
{
	if(this->shader != nullptr)
	{
		shader->Bind();
		
	}
}

void Material::Unbind()
{
	if(this->shader != nullptr)
	{
		
		shader->Unbind();
	}
}

/*
void Material::AddParameter(std::string name, float parameter)
{
	shader->AddParameter(name, parameter);
}

void Material::AddParameter(std::string name, glm::vec2 parameter)
{
	shader->AddParameter(name, parameter);
}

void Material::AddParameter(std::string name, glm::vec3 parameter)
{
	shader->AddParameter(name, parameter);
}

void Material::AddParameter(std::string name, void* uniformBlock, GLuint size, GLuint bindingPt)
{
	shader->AddParameter(name, uniformBlock, size, bindingPt);
}

void Material::AddParameter(Shader::TextureType type, std::shared_ptr<Texture> texParameter)
{
	shader->AddParameter(type, texParameter);
}
*/